#include "Consultant.h"

using namespace rapidxml;

const std::string Consultant::CONS_NODE = "consultant";
const std::string Consultant::CONS_FIRST_NAME_NODE = "firstName";
const std::string Consultant::CONS_NAME_NODE = "name";
const std::string Consultant::CONS_MAIL_NODE = "mail";
const std::string Consultant::CONS_ACCOR_NODE = "accor";
const std::string Consultant::CONS_SMOKE_NODE = "smoke";

rapidxml::xml_node<>* Consultant::constructNode(rapidxml::xml_document<>* doc) const{
	
	xml_node<>* consNode = doc->allocate_node(node_element, Consultant::CONS_NODE.c_str());

	xml_node<>* firstNameNode = doc->allocate_node(node_element, Consultant::CONS_FIRST_NAME_NODE.c_str(), getFirstName()->c_str());
	xml_node<>* nameNode = doc->allocate_node(node_element, Consultant::CONS_NAME_NODE.c_str(), getName()->c_str());
	xml_node<>* mailNode = doc->allocate_node(node_element, Consultant::CONS_MAIL_NODE.c_str(), getMail()->c_str());
	xml_node<>* accorNode = doc->allocate_node(node_element, Consultant::CONS_ACCOR_NODE.c_str(), getAccor()->c_str());
	
	std::stringstream smokerBuff;
	smokerBuff << isSmoker();

	xml_node<>* smokeNode = doc->allocate_node(node_element, Consultant::CONS_SMOKE_NODE.c_str(), doc->allocate_string(smokerBuff.str().c_str()));

	consNode->append_node(firstNameNode);
	consNode->append_node(nameNode);
	consNode->append_node(mailNode);
	consNode->append_node(accorNode);
	consNode->append_node(smokeNode);

	return consNode;
}